package com.mycinema.Interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.mycinema.entity.User;

public class LogInterceptor extends HandlerInterceptorAdapter {

	long start;

	// 统计每个动作(controller的方法)的执行时间,
	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {

		start = System.currentTimeMillis();
		System.out.println("进入请求:" + request.getRequestURI());
		return true;

	}
	
	@Override//验证方法名
	  public void postHandle(HttpServletRequest request,
	  			HttpServletResponse response, Object handler,ModelAndView mv) throws Exception {
	  		long end =System.currentTimeMillis();
	  		System.out.println("请求完成,使用时间="+(end-start));
	  	
	  	}
}
